from pydantic import BaseModel
from typing import Optional, Dict, Any
from datetime import datetime

class ServerBase(BaseModel):
    name: str
    ip_address: str
    port: int = 22
    username: str
    password: str
    status: str = "active"
    extra_metadata: Optional[Dict[str, Any]] = {}

class ServerCreate(ServerBase):
    pass

class ServerResponse(BaseModel):
    id: int
    name: str
    hostname: Optional[str] = None
    ip_address: str
    port: Optional[int] = 22
    username: Optional[str] = None
    status: Optional[str] = "active"
    os_type: Optional[str] = None
    os_version: Optional[str] = None
    cpu_cores: Optional[int] = None
    memory_total: Optional[int] = None
    disk_total: Optional[int] = None
    cpu_usage: Optional[float] = 0.0
    memory_usage: Optional[float] = 0.0
    disk_usage: Optional[float] = 0.0
    load_average: Optional[float] = 0.0
    network_in: Optional[float] = 0.0
    network_out: Optional[float] = 0.0
    ffmpeg_path: Optional[str] = "/usr/bin/ffmpeg"
    recording_path: Optional[str] = "/data/recordings"
    max_concurrent_tasks: Optional[int] = 5
    extra_metadata: Optional[Dict[str, Any]] = {}
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None
    last_seen: Optional[datetime] = None

    class Config:
        from_attributes = True